package com.tarot.aspect.logger.controller;

import com.tarot.aspect.logger.dto.GuestInfoRequest;
import com.tarot.aspect.logger.dto.GuestInfoResponse;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Random;

/**
 * @author zhaohejia
 * @version 1.0.0
 * @date 2020/11/6
 */
@RestController
@RequestMapping("/guest")
public class GuestController {

    /**
     * 根据客户编号查询客户信息
     *
     * @param guest 客户编号
     * @return 客户信息
     */
    @PostMapping("/getGuestInfo")
    @ResponseBody
    public GuestInfoResponse getGuestInfo(@RequestBody @Valid GuestInfoRequest guest) {
        //测试异常环绕通知
        //int c = 1/0;
        Random random = new Random();
        GuestInfoResponse guestInfo = new GuestInfoResponse();
        guestInfo.setGuestId(guest.getGuestId())
                .setGuestName("tarot-" + random.nextInt(100))
                .setGuestAddress("新一区")
                .setGuestProfession("程序员")
                .setGuestName("谢小鱼");
        return guestInfo;
    }


}
